package com.mxpio.erp.common.plan.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author : wpp
 * @Datetime : 2023/4/11 17:01
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "v_mb_erp_plan_sp_of")
@NoArgsConstructor
@AllArgsConstructor
@Schema(description="销售预测-销售订单冲销明细视图")
public class SalePredictionOffsettingFlowVO implements DictAble, Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_", updatable = false)
    @Generator
    @Schema(description = "流水号")
    private String id;

    @Column(name = "ITEM_CODE_")
    @Schema(description = "物料代码")
    private String itemCode;

    @Column(name = "SO_BIZ_NO_")
    @Schema(description = "销售单单号")
    private String soBizNo;

    @Column(name = "SO_BIZ_LINE_NO_")
    @Schema(description = "销售单行号")
    private String soBizLineNo;

    @Column(name = "SP_BIZ_NO_")
    @Schema(description = "销售预测单单号")
    private String spBizNo;

    @Column(name = "SP_BIZ_LINE_NO_")
    @Schema(description = "销售预测单行号")
    private String spBizLineNo;

    @Column(name = "PN_CODE_")
    @Schema(description = "客户编号")
    private String pnCode;

    @Column(name = "PN_NAME_")
    @Schema(description = "客户名称")
    private String pnName;


    @Column(name = "ITEM_NAME_")
    @Schema(description = "物料名称")
    private String itemName ;

    @Column(name = "ITEM_SPEC_")
    @Schema(description = "规格型号")
    private String itemSpec;


    @Column(name = "QUANTITY_")
    @Schema(description = "冲销数量")
    private BigDecimal quantity;


    @Column(name = "UNIT_CODE_")
    @Schema(description = "单位编号")
    @Dict(dicCode="ERP_TECH_UNIT_CODE")
    private String unitCode;

    @Column(name = "DRAWING_NO_")
    @Schema(description = "图号")
    private String drawingNo;

    @Column(name = "ITEM_GROUP_CODE_")
    @Schema(description = "物料组")
    @Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
    private String itemGroupCode;


    @Column(name = "SP_QUANTITY_")
    @Schema(description = "预测数量")
    private BigDecimal spQuantity;


    @Column(name = "DEMAND_DATE_")
    @Schema(description = "预测日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date demandDate;

    @Column(name = "SO_QUTITY_")
    @Schema(description = "单据数量")
    private BigDecimal soQuantity;

    @Column(name = "DELIVER_DATE_")
    @Schema(description = "交付日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date deliverDate;
    @Transient
    private Map<String, String> textMap;

    public String putText(String key, String value) {
        if (textMap == null) {
            textMap = new HashMap<>();
        }
        return textMap.put(key, value);
    }
}
